#include <bits/stdc++.h>

using namespace std;
int a[1010];
int main()
{
	int q = 0;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++)
	{
		int b = a[i];
		for (int j = 0; j < n; j++)
		{
			if (b == 0)
			{
				q = q ^ i;
				break;
			}
			b = a[b];
		}
	}
	cout << q;
	return 0;
}
